/*******************************************************************************
* CHIPSEA F61 POWER HAL
*******************************************************************************/

#include "hal_aw_86802_power.h"

#ifdef AW_86802

#include "system_control.h"


EM_POWER em_power;

ST_POWER st_power = {
	I2C_START,
	IIC_TIME_OUT,
};


void hal_power_control(void)
{
	switch(st_power.state)
	{
	case ENTER_SLEEP:
// GPIO_WriteBits(GPIO_PIN_8, 1);
		EnterDeepSleep2IICReset();
// GPIO_WriteBits(GPIO_PIN_8, 0);
		break;
	case I2C_START:
		st_power.time_out_count = IIC_TIME_OUT;
		st_power.state = I2C_WORKING;

		break;
	case I2C_WORKING:
		EnterSleep();
		st_power.time_out_count -= st_sys_ctr.period;

		if(st_power.time_out_count <= 0)
		{
			st_power.state = ENTER_SLEEP;
		}
		
		break;
	default:
		break;
	}

}

//////////////////////////////////////////////////////////////////////////////////////////

#endif /* End of CS_F61 */
